#ifndef JPSOCKET_H
#define JPSOCKET_H
#include <time.h>
#include <QObject>
#include <QDebug>
#include <QTcpServer>
#include <QTcpSocket>
class JpSocket : public QObject
{
    Q_OBJECT
public:
    explicit JpSocket(QObject *parent = 0);
    ~JpSocket();
    void serverInit();
    void clientInit();
signals:

public slots:
    void jpnewConnection();
    void JPConnectionDisconnect();
    void readClient();
    void readServer();

protected:
    QTcpServer *server;
    QTcpSocket *client;
    QString _ip;
    quint16 _port;
    QString _serverip;
    quint16 _serverport;
    virtual void serverConnectionLogic(QTcpSocket *sk);
    virtual void serverDisConnectionLogic(QTcpSocket *sk);
    virtual void readClientLogic();
    virtual void readServerLogic(QTcpSocket* socket);
    void sSend(char *data, int cid);

};

#endif // JPSOCKET_H
